package com.roadjava.rbac.mapper;
//数据访问层，继承自JpaRepository，提供对Recommendation实体的数据库操作，包括分页查询和自定义查询。
import com.roadjava.rbac.bean.Recommendation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface RecommendationRepository extends JpaRepository<Recommendation, Long> {
    Logger logger = LoggerFactory.getLogger(RecommendationRepository.class);

    @Query("SELECT r FROM Recommendation r WHERE r.userId = :userId AND r.resourceID = :resourceID AND r.userBehavior = :userBehavior")
    Page<Recommendation> findRecommendations(Integer userId, Long resourceID, String userBehavior, Pageable pageable);
}